﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


// Condition: Write a program that reads two numbers N and K and generates all the
//            variations of K elements from the set [1...N].

class AllVariationOfKFromN
{
    static void Main(string[] args)
    {
        Console.Write("Enter N: ");
        int n = int.Parse(Console.ReadLine());
        Console.Write("Enter K: ");
        int k = int.Parse(Console.ReadLine());



        for (int i = 0; i < Math.Pow(n, k); i++)
        {
            int variation = i;
            int[] num = new int[k];
            for (int j = 0; j < k; j++)
            {
                num[k - j - 1] = variation % n;
                variation = variation / n;
            }

            Console.Write("{0}{1}", '{', num[0] + 1);
            for (int j = 1; j < k; j++)
            {
                Console.Write(", {0}", num[j] + 1);
            }
            Console.WriteLine("}");
        }
    }
}

